Skip to content

Conversation

@fhyrox
Copy link
Member

@fhyrox fhyrox commented Jan 15, 2026

Summary by CodeRabbit

  • New Features

    • Added colored, timestamped console logging with severity levels (log, warn, error, debug).
    • Introduced a base client with built-in logging support and configurable log level.
  • Chores

    • Added a runtime dependency (chalk) and a peer dependency (discord.js).
    • Updated package manifest and ignore patterns to exclude test and examples directories.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 15, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Adds a BaseClient class (extending discord.js Client) that composes a LoggerInstance; introduces a console LoggerInstance with colored, timestamped output using chalk; updates package.json to add chalk and a discord.js peerDependency; and adds Test and examples to .npmignore.

Changes

Cohort / File(s) Summary
Package configuration
\.npmignore, package.json
.npmignore: added ignore patterns Test and examples. package.json: added "chalk": "^4.1.2" under dependencies and "discord.js": ">=14.25.1" under peerDependencies.
Base classes
src/classes/base/BaseClient.ts, src/classes/base/Logger.ts
New BaseOptions interface and default-export BaseClient class (extends discord.js Client) with public logger: LoggerInstance. New LoggerInstance class with log, warn, error, debug, timestamping and colored labels (uses chalk).

Sequence Diagram(s)

sequenceDiagram
  participant App as Application
  participant Base as BaseClient
  participant DJ as discord.js Client (super)
  participant Log as LoggerInstance

  App->>Base: instantiate BaseClient(opts)
  Base->>DJ: super(opts) (Client ctor)
  Base->>Log: new LoggerInstance(opts.logLevel)
  Base-->>App: BaseClient instance (contains logger)
  App->>Base: call base.logger.log(...)
  Base->>Log: log(...)
  Log-->>App: console output (timestamped, colored)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nibble bytes and tweak a trace,
A BaseClient snug in its logging place.
Chalk paints labels, timestamps hum,
I hop through code — a tiny drum.
Tests and examples kept out of the crate.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Feat/logger enhancement' is partially related to the changeset. While the PR does add a new logger component, it encompasses broader changes including a base client abstraction, dependencies, and build configuration updates that extend beyond just logger enhancement.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/logger-enhancement


📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between a5e3844 and f241241.

📒 Files selected for processing (1)
  • src/classes/base/BaseClient.ts

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In @.npmignore:
- Around line 7-8: The comment "# Test" in the .npmignore is inconsistent with
the actual ignore pattern "examples"; either update the comment to "# Examples"
to match the pattern, or add the appropriate test ignore patterns (e.g., "test",
"tests", "spec", or "Test") below the comment so test files are excluded from
the npm package; adjust the entry that currently reads "examples" only if you
intend to keep or rename that pattern.

In `@src/classes/base/Logger.ts`:
- Around line 6-8: The timestamp getter in class Logger uses locale-dependent
toLocaleTimeString(); change the implementation of the private get timestamp()
accessor to return a consistent ISO 8601 timestamp (e.g. use new
Date().toISOString()) wrapped in the same chalk.gray(`[...`] format so logs are
consistent across environments; update the private get timestamp() method
accordingly.
- Line 4: The Logger class contains an unnecessary empty constructor; remove the
empty constructor declaration from the Logger class (the constructor() { } in
class Logger) so the class uses the default implicit constructor and no behavior
changes are made — ensure no other code relies on an explicit constructor
signature before deleting it.
- Around line 22-24: The Logger.debug method currently always emits debug
output; add log-level control to suppress debug logs unless enabled by
introducing a log level property (e.g., this.level or this.logLevel) on the
Logger class and a helper like isLevelEnabled(level) or compare numeric levels,
defaulting to "info" in production; update debug(...args: any[]) to check the
logger's level before calling console.debug and expose a way to set the level
(constructor param or setLevel method) so callers can enable "debug" when
needed.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 74afa91 and 9cc083c.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • .npmignore
  • package.json
  • src/classes/base/BaseClient.ts
  • src/classes/base/Logger.ts
🧰 Additional context used
🧬 Code graph analysis (1)
src/classes/base/BaseClient.ts (1)
src/classes/base/Logger.ts (1)
  • LoggerInstance (3-25)
🔇 Additional comments (2)
package.json (1)

43-47: LGTM!

Good choices:

  • chalk ^4.1.2 is correct for CommonJS compatibility (v5+ is ESM-only)
  • discord.js as a peer dependency allows consumers to control the exact version
src/classes/base/BaseClient.ts (1)

1-12: LGTM!

Clean implementation:

  • Extending ClientOptions via BaseOptions allows future framework-specific options
  • Logger integration is straightforward
  • Constructor properly delegates to parent

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@package.json`:
- Around line 46-48: The peerDependencies entry for "discord.js" is too
permissive (">=14.25.1"); change it to a stricter semver range such as
"^14.25.1" (or "~14.25.1" if you want only patch updates) in package.json's
"peerDependencies" so you accept only compatible 14.x releases and avoid
automatically matching future major versions; update the "discord.js" value
accordingly and run a quick `npm install`/`pnpm install` check to verify no
conflicts.

In `@src/classes/base/BaseClient.ts`:
- Around line 8-14: The logger property on BaseClient should be immutable: mark
the class property as readonly (change "logger: LoggerInstance;" to "readonly
logger: LoggerInstance;") so it cannot be reassigned after the constructor, and
ensure no other code reassigns this.logger (if any reassignment exists, refactor
to mutate logger internals instead). Keep the LoggerInstance initialization in
the constructor as-is (this.logger = new LoggerInstance(...)).
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 9cc083c and a5e3844.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • package.json
  • src/classes/base/BaseClient.ts
  • src/classes/base/Logger.ts
🧰 Additional context used
🧬 Code graph analysis (1)
src/classes/base/BaseClient.ts (1)
src/classes/base/Logger.ts (2)
  • LogLevel (2-2)
  • LoggerInstance (11-45)
🔇 Additional comments (5)
package.json (1)

33-35: Good choice using chalk v4.x for CommonJS compatibility.

Since the project uses CommonJS ("type": "commonjs"), pinning to chalk ^4.1.2 is correct—v5+ is ESM-only and would break the build.

src/classes/base/Logger.ts (3)

1-9: Well-structured log level system.

The type definition and priority mapping provide a clean foundation for level-based filtering. The numeric priorities correctly order debug < log < warn < error.


11-24: Clean implementation addressing previous feedback.

The constructor now serves a purpose (setting log level), the timestamp uses ISO format for consistency across environments, and the shouldLog method enables proper level filtering.


26-44: Log methods correctly implement level gating.

Each method properly checks shouldLog before emitting output. The colored labels provide good visual distinction.

src/classes/base/BaseClient.ts (1)

1-6: Clean interface extension and imports.

The BaseOptions interface properly extends ClientOptions while adding the optional logLevel property with the correct type from Logger.ts.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@vrdons
Copy link
Member

vrdons commented Jan 15, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 15, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@vrdons vrdons merged commit 22b2cb1 into main Jan 15, 2026
3 checks passed
@vrdons vrdons deleted the feat/logger-enhancement branch January 15, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants